#include "GameTutorial.h"


GameTutorial::GameTutorial(void)
{

	CGESurface* test = CGESpriteMgr->LoadImage("test1.png");
	CGESprite* test1 = new CGESprite(*test,0,0,0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
	test = CGESpriteMgr->LoadImage("test2.png");
	CGESprite*  test2 = new CGESprite(*test,0,0,0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
	test = CGESpriteMgr->LoadImage("test3.png");
	CGESprite*  test3 = new CGESprite(*test,0,0,0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
	test = CGESpriteMgr->LoadImage("test4.png");
	CGESprite*  test4 = new CGESprite(*test,0,0,0,0,SCREEN_WIDTH,SCREEN_HEIGHT);

	m_vecTips.push_back(test1);
	m_vecTips.push_back(test2);
	m_vecTips.push_back(test3);
	m_vecTips.push_back(test4);
	m_CurTip = test1;

	m_NextBtn = new CGEButton("buttonSmall.png",210,0,30,20);
	m_NextBtn->SetScale(1.2f,1.0f);
	m_NextBtn->AddText("Next","TutorialNext");

	m_PrevBtn = new CGEButton("buttonSmall.png",150,0,30,20);
	m_PrevBtn->SetScale(1.2f,1.0f);
	m_PrevBtn->AddText("Prev","TutorialNext");

	m_ReturnBtn = new CGEButton("buttonSmall.png",270,0,30,20);
	m_ReturnBtn->SetScale(1.2f,1.0f);
	m_ReturnBtn->AddText("Return","TutorialNext");
}

GameTutorial::~GameTutorial(void)
{
}

bool GameTutorial::Update(CGEEvent* inputEvent)
{
	m_NextBtn->HandleEvents(inputEvent);
	if(m_NextBtn->GetPressed())
	{
		for(int index = 0;index < m_vecTips.size(); index++)
		{
			if(m_vecTips[index] == m_CurTip)
			{
				if(index < m_vecTips.size() - 1)
				{
					m_CurTip = m_vecTips[index + 1];
				}
				else
				{
					m_CurTip = m_vecTips[0];
				}
				break;
			}
		}
		m_NextBtn->SetPressed(false);
	}
	m_PrevBtn->HandleEvents(inputEvent);
	if(m_PrevBtn->GetPressed())
	{
		for(int index = 0;index < m_vecTips.size(); index++)
		{
			if(m_vecTips[index] == m_CurTip)
			{
				if(index > 0)
				{
					m_CurTip = m_vecTips[index - 1];
				}
				else
				{
					m_CurTip = m_vecTips[m_vecTips.size() - 1];
				}
				break;
			}
		}
		m_PrevBtn->SetPressed(false);
	}
	m_ReturnBtn->HandleEvents(inputEvent);
	if(m_ReturnBtn->GetPressed())
	{
		m_ReturnBtn->SetPressed(false);
		return false;
	}

	return true;
}

void GameTutorial::Render()
{
	for(vector<CGESprite*>::iterator it = m_vecTips.begin(); it != m_vecTips.end(); it++)
	{
		if((*it) == m_CurTip)
		{
			m_CurTip->RenderSpr();
		}
	}

	m_NextBtn->Render();
	m_PrevBtn->Render();
	m_ReturnBtn->Render();
}